/**
 * Created on 2007-03-06 13:24
 */
package manager;

/**
 * @author David Wallin
 */
public abstract class Manager implements IManager
{
	private boolean		m_WasInitialized = false;
	
	/* (non-Javadoc)
	 * @see manager.IManager#initialize()
	 */
	public final void initialize()
	{
		if(!m_WasInitialized)
		{
			m_WasInitialized = true;
			doInitialize();
		}
	}
	
	/* (non-Javadoc)
	 * @see manager.IManager#teardown()
	 */
	public final void tearDown()
	{
		if(m_WasInitialized)
		{
			m_WasInitialized = false;
			doTearDown();
		}
	}
	
	/* (non-Javadoc)
	 * @see manager.IManager#update(int)
	 */
	public final void update(int deltaTime)
	{
		if(m_WasInitialized)
		{
			doUpdate(deltaTime);
		}
	}
	
	/**
	 * Put initialization code in override of this method
	 */
	protected void doInitialize()
	{
	}
	
	/**
	 * Put tear down code in override of this method
	 */
	protected void doTearDown()
	{
	}
	
	/**
	 * Put update code in override of this method
	 * 
	 * @param deltaTime milliseconds since last call
	 */
	protected void doUpdate(int deltaTime)
	{
	}
}
